1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| if(condition){………} if($variable ~ '^/product' ){………} 举例: if ($http_user_agent ~ MSIE) { #只要“$http_user_agent”配置MSIE的 rewrite ^(.*)$ /msie/$1 break; #URL地址前面加"/msie" }
if ($http_cookie ~* "id=([^;]+)(?:;|$)") { set $id $1; }
if ($request_method = POST) { return 405; }
if ($slow) { limit_rate 10k; }
if ($request_uri ~) { return 403; }
if ($request_uri ~ "/test.html") { #根据访问地址跳转到目标地址 rewrite ^ http://new.ngins.net; }
if (-x "/data/test.sh") { #根据文件是否有执行权限,跳转到目标 rewrite ^ http://new.ngins.net; }
|